<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style type="text/css">
    * {
        padding: 0;
        margin: 0;
    }

    .box {
        width: 500px;
        height: 500px;
        position: relative;
    }

    #canvas,
    #area {
        position: absolute;
        left: 0;
        top: 0;
    }

    #canvas {
        display: block;
    }

    #area {
        width: 100%;
        height: 100%;
        background: white;
        font-size: 48px;
        font-weight: bold;
        text-align: center;
        line-height: 500px;
    }
    </style>
</head>

<body>
    <div class="box">
        <div id="area">再来一次</div>
        <canvas id="canvas" width="500" height="500"></canvas>
    </div>
    <script>
    var info = ['再来一次', '一等奖', '二等奖', '三等奖' , '特等奖'];
    var text = info[Math.floor(Math.random() * info.length)];
    var area = document.getElementById('area');
    area.innerHTML = text;

    var canvas = document.getElementById('canvas');
    var ctx = canvas.getContext('2d');
    ctx.fillStyle = '#999';
    ctx.fillRect(0, 0, 500, 500);
    /*使用 destination-out 能够把之前画过的这部分内容变成透明:*/
    ctx.globalCompositeOperation = 'destination-out'
    canvas.onmousedown = function() {
        canvas.onmousemove = function(e) {
            var x = e.offsetX;
            var y = e.offsetY;
            ctx.beginPath();
            ctx.arc(x, y, 50, 0, Math.PI * 2, false);
            ctx.closePath();
            ctx.fillStyle = 'white';
            ctx.fill();
        }
        document.onmouseup = function() {
            canvas.onmousemove = null;
        }
    }
    </script>
</body>

</html>